<?php

namespace api\models;

use Yii;

/**
 * This is the model class for table "user".
 *
 * @property integer $id
 * @property string $outer_id
 * @property string $username
 * @property string $auth_key
 * @property string $password_hash
 * @property string $password_reset_token
 * @property string $email
 * @property integer $status
 * @property string $created_at
 * @property string $updated_at
 * @property string $active_at
 * @property string $open_at
 * @property string $phone
 * @property string $wechart_id
 * @property string $police_wechat_id
 * @property integer $wechat_status
 * @property integer $duty
 */
class User extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('test2');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['username', 'auth_key', 'password_hash', 'created_at', 'updated_at'], 'required'],
            [['status', 'wechat_status', 'duty'], 'integer'],
            [['created_at', 'updated_at', 'active_at', 'open_at'], 'safe'],
            [['outer_id'], 'string', 'max' => 20],
            [['username', 'auth_key', 'password_hash', 'password_reset_token', 'email', 'wechart_id'], 'string', 'max' => 255],
            [['phone'], 'string', 'max' => 30],
            [['police_wechat_id'], 'string', 'max' => 64],
            [['username'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'outer_id' => 'Outer ID',
            'username' => 'Username',
            'auth_key' => 'Auth Key',
            'password_hash' => 'Password Hash',
            'password_reset_token' => 'Password Reset Token',
            'email' => 'Email',
            'status' => 'Status',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'active_at' => 'Active At',
            'open_at' => 'Open At',
            'phone' => 'Phone',
            'wechart_id' => 'Wechart ID',
            'police_wechat_id' => 'Police Wechat ID',
            'wechat_status' => 'Wechat Status',
            'duty' => 'Duty',
        ];
    }
}
